package tw.asap.plus.ui.custom;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import tw.asap.plus.R;


public class MineItemView extends LinearLayout {

    private ImageView mine_item_image;
    private TextView mine_item_title;
    private ImageView mine_item_indent_indicate;

    public MineItemView(Context context) {
        super(context);
    }

    public MineItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyMenu);
        String mText = a.getString(R.styleable.MyMenu_menu_title);
        int mIconId = a.getResourceId(R.styleable.MyMenu_menu_icon, 0);
        LayoutInflater.from(context).inflate(R.layout.view_mine_item, this);
        mine_item_image = (ImageView) findViewById(R.id.mine_item_image);
        mine_item_image.setImageResource(mIconId);
        mine_item_title = (TextView) findViewById(R.id.mine_item_title);
        mine_item_title.setText(mText);
        mine_item_indent_indicate = (ImageView) findViewById(R.id.mine_item_indent_indicate);
    }


    public void setIndicateVisibility(int visibility) {
        if (mine_item_indent_indicate != null)
            mine_item_indent_indicate.setVisibility(visibility);
    }

    public void setImageRes(int resId) {
        if (mine_item_image != null)
            mine_item_image.setImageResource(resId);
    }

    public void setTitle(String title) {
        if (mine_item_title != null)
            mine_item_title.setText(title);
    }
}
